
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you want to add, delete, or rename functions or slots, use
** Qt Designer to update this file, preserving your code.
**
** You should not define a constructor or destructor in this file.
** Instead, write your code in functions called init() and destroy().
** These will automatically be called by the form's constructor and
** destructor.
*****************************************************************************/

#include <qvalidator.h>
#include <qcolordialog.h>
#include <qcanvas.h>
#include <qfont.h>
#include <qfontdialog.h>


#include "mainwindow.h"

void formConfig::init()
{



}

void formConfig::chooseBackgroundColor()
{
    QColor oldColor = btBackgroundColor->paletteBackgroundColor();
    QColor newColor = QColorDialog::getColor( oldColor , this);
    if (newColor.isValid()){
       btBackgroundColor->setPaletteBackgroundColor( newColor );
       enableBtOk();
    }

}


void formConfig::chooseLinesColor()
{
   QColor oldColor = btLinesColor->paletteBackgroundColor();
   QColor newColor = QColorDialog::getColor( oldColor , this);
   if (newColor.isValid()){
      btLinesColor->setPaletteBackgroundColor( newColor );
      enableBtOk();
   }

}


void formConfig::chooseTextColor()
{
   QColor oldColor = btTextColor->paletteBackgroundColor();
   QColor newColor = QColorDialog::getColor( oldColor , this);

   if (newColor.isValid()){
      btTextColor->setPaletteBackgroundColor( newColor );
   enableBtOk();
   }

}


void formConfig::chooseSelectedColor()
{
   QColor oldColor = btSelectedColor->paletteBackgroundColor();
   QColor newColor = QColorDialog::getColor( oldColor , this);

   if (newColor.isValid()){
      btSelectedColor->setPaletteBackgroundColor( newColor );
      enableBtOk();
   }

}

void formConfig::enableBtOk()
{
   btOk->setEnabled(true);
}


void formConfig::chooseFontMap()
{
   bool ok;
   QFont font = QFontDialog::getFont( &ok, textFontTemplate->font(), this );

   if ( ok ) {
      textFontTemplate->setFont( font );
      enableBtOk();
   }

}


void formConfig::testSQLConnect()
{


   QSqlDatabase *db = QSqlDatabase::addDatabase(boxDbSelect->currentText());
   db->setHostName(lineServerAddress->text());
   db->setDatabaseName(lineDatabaseName->text());
   db->setUserName(lineUser->text());
   db->setPassword(linePassword->text());

   if (!db->open()) {
      db->lastError().showMessage();
  } else{
        enableBtOk();
   }
}



void formConfig::accept()
{
   done(true);
 }


void formConfig::enableButtons()
{
 
    if ( listBoxUtility->currentItem()   == -1 ) {
	 btRemove->setEnabled(false);
	 btChange->setEnabled(false);
    }else{
	 btRemove->setEnabled(true);
	 btChange->setEnabled(true);
    }
    
}
